package com.property.manage.controller.renovation;

import com.guardchina.framework.mybatis.model.CustomPage;
import com.property.manage.model.renovation.DepositVo;
import com.property.manage.model.renovation.RenovationVo;
import com.property.manage.model.system.SysSet;
import com.property.manage.service.renovation.DepositService;
import com.property.manage.service.renovation.RenovationService;
import com.property.manage.service.system.SysSetService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.List;

/**
 * 描述
 *
 * @author lwb
 * @since 2020/7/15
 */
@Api(tags = "装修押金管理")
@RestController
@RequestMapping("/deposit")
@AllArgsConstructor
@Validated
public class DepositController {
    @Autowired
    private DepositService depositService;


    @ApiOperation("列表")
    @GetMapping("/page")
    public CustomPage<DepositVo> getPage(@ApiParam("当前页码") @RequestParam("pageNo") @NotNull(message = "请输入当前页码") Long pageNo,
                                         @ApiParam("每页条数") @RequestParam("pageSize") @NotNull(message = "请输入每页条数") Long pageSize,
                                         @ApiParam("付款方") @RequestParam(value = "payer", required = false) String payer,
                                         @ApiParam("小区id") @RequestParam(value = "villageId", required = false) Integer villageId){
        return depositService.page(pageNo,pageSize,payer,villageId,1);
    }

    @ApiOperation("押金缴费")
    @GetMapping("/deposit")
    public void deposit(@ApiIgnore @RequestParam("userId") @NotNull(message = "您尚未登录") Integer userId,@ApiParam("押金管理id")@RequestParam("id") @NotNull(message = "id不能为空") Integer id,
            @ApiParam("打印 传1") @RequestParam(value = "villageId",required = false) Integer printing){
        depositService.deposit(id,userId,printing);
    }
    @ApiOperation("退押金")
    @GetMapping("/Refund")
    public void Refund(@ApiIgnore @RequestParam("userId") @NotNull(message = "您尚未登录") Integer userId,
            @ApiParam("押金管理id")@RequestParam("id") @NotNull(message = "id不能为空") Integer id,
                       @ApiParam("退费金额")@RequestParam("refund") @NotNull(message = "退费金额不能为空") BigDecimal refund
                       ){
        depositService.refund(id,refund,userId);
    }
}
